package com.wenlin.myproduction.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.base.BaseActivity;
import com.wenlin.myproduction.base.BaseSwipeActivity;
import com.wenlin.myproduction.util.UI;
import com.wenlin.myproduction.util.ValCommon;
import com.wenlin.myproduction.widget.PicNumberView;

import butterknife.BindView;
import butterknife.OnClick;

public class NumberViewActivity extends BaseSwipeActivity {
    @BindView(R.id.nv1)
    PicNumberView nv1;
    @BindView(R.id.nv2)
    PicNumberView nv2;
    @BindView(R.id.nv3)
    PicNumberView nv3;
    @BindView(R.id.nv4)
    PicNumberView nv4;

    private int number;

    @Override
    public int getContentView() {
        return R.layout.activity_number_view;
    }

    public static void start(BaseActivity activity) {
        Intent intent = new Intent(activity, NumberViewActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(ValCommon.NUMBER_VIEW);
    }

    @OnClick({R.id.tv, R.id.tv2})
    void click(View view) {
        switch (view.getId()) {
            case R.id.tv:
                number = 0;
                UI.setNumber(nv1, number);
                UI.setNumber(nv2, number);
                UI.setNumber(nv3, number);
                UI.setNumber(nv4, number);
                break;
            case R.id.tv2:
                number += 1;
                if (number > 10) number = 0;
                UI.setNumber(nv1, number);
                UI.setNumber(nv2, number);
                UI.setNumber(nv3, number);
                UI.setNumber(nv4, number);
                break;
            default:
        }
    }
}